layui.define(['table', 'form', 'http', 'laydate', 'dropdown', 'public', 'util'], function (exports) {
    "use strict";
    var MOD_NAME = 'rntable', $ = layui.jquery;
    var group_num = layui.public.GetQuery('group_num') || 'index';
    var tab_num = layui.public.GetQuery('tab_num') || 'all';
    var TableConfig = {};
    var setting = '';
    var SeleteData = {};
    var orderraw = '';
    var context = new function () {
        this.init = function (url = '') {//初始化
            setting = url;
            var urldata = layui.public.GetQueryAll() || {};
            var data = {
                "tab_num": tab_num,
                "group_num": group_num,
                "urldata": JSON.stringify(urldata),
            }

            layui.http.SendAjax(url, data, [], function (res) {
                layui.public.ViewTpl(res.data, 'view_body_data', 'view_body');
                var search = res.data.header.search || [];
                if (search.length != 0) {
                    layui.rnform.GetForm(search, '.table_from');
                    for (var k = 0; k < search.length; k++) {
                        var width = search[k].width || '';
                        if (width) {
                            $('.table_from .design-box').eq(k).css('width', width)
                        }
                        $('.table_from .design-box').eq(k).attr('class', 'design-box table_from_item')
                    }
                }
                var header = res.data.header || [];
                var table = res.data.table || [];
                table.cols = layui.rntable.GetCols(table.cols, table.elem);
                table.cols = layui.rntable.GetHeadButton(header.button, table.cols);
                layui.rntable.GetTableButton(table);
                layui.rntable.GetTableData(table);
                layui.rntable.GetSelect();
                TableConfig[table.elem] = res.data;
            })
        }

        this.TableMenu = function (obj) {
            $(".head_menu li").removeClass("on");
            $(obj).addClass("on");
            layui.rntable.init(setting);
        }

        //获取表头
        this.GetCols = function (arr = [], tableid = '') {
            for (var k = 0; k < arr.length; k++) {
                var select = arr[k]['select'] || '';
                var range = arr[k]['range'] || '';
                var action = arr[k]['action'] || '';
                var title = '';
                var select_title = '';
                var desc = arr[k]['desc'] || '';
                var options_data = arr[k]['options_data'] || [];
                var z = 1;
                if (arr[k]['field'] == 'create_id') {
                    arr[k]['field'] = 'create_name';
                }
                if (arr[k]['field'] == 'update_id') {
                    arr[k]['field'] = 'update_name';
                }

                if (desc == 1) {
                    title += '<li class="layui-table-sort layui-inline">' + '<i class="table-sort-val layui-edge layui-table-sort-asc" title="升序" data-id="asc" data-val="' + arr[k]['field'] + ' asc" onclick="layui.rntable.GetSort(this)"></i>' + '<i class="table-sort-val layui-edge layui-table-sort-desc" title="降序" data-id="desc" data-val="' + arr[k]['field'] + ' desc" onclick="layui.rntable.GetSort(this)"></i>' + '</li>';
                    z = 2;
                }
                if (select == 1) {
                    select_title = '<li lay-filter="search_select" lay-submit data-table="' + tableid + '" id="' + arr[k]['field'] + '" class="table_search"><i class="ruinuo-icon icon-filter"></i></li>';
                    z = 2;
                }
                if (z == 2) {
                    var newtitle = '<div class="display_flex table_title">';
                    newtitle += '<li class="flex_1" id="title_' + arr[k]['field'] + '" data-title="' + arr[k]['title'] + '">' + arr[k]['title'] + '</li>';
                    if (title) {
                        newtitle += title;
                    }
                    if (select_title) {
                        newtitle += select_title;
                    }
                    newtitle += '</div>';
                    arr[k]['title'] = newtitle;
                }
                arr[k]['templet'] = layui.rntable.TableAction(arr[k], tableid);
            }
            var choose = layui.public.GetQuery('choose') || 0;
            switch (Number(choose)) {
                case 1:
                    arr.unshift({type: 'checkbox', Width: 70});
                    break;
                case 2:
                    arr.unshift({type: 'radio', Width: 70});
                    break;
            }


            return [arr];
        }
        this.GetSource = function (value = '', field = '', tableelem = 'datatable') {
            if (value || value == 0) {
                var rows = TableConfig[tableelem]['source'][field] || [];
                var list = rows.rows || [];
                value = layui.rntable.ChangeData(value, list)
            }
            return value;
        }
        this.ChangeData = function (value = '', list = []) {
            var value = '' + value + '';
            var val = '';
            for (var k = 0; k < list.length; k++) {
                var item = value.split(',');
                for (var kk = 0; kk < item.length; kk++) {
                    if (item[kk] == list[k].value) {
                        val += list[k].label + ',';
                    }
                }
            }
            return val.replace(/,([^,]*)$/, "$1");
            ;
        }
        this.GetImgs = function (value = '') {
            if (value) {
                var item = value.split(',');
                var html = '';
                for (var kk = 0; kk < item.length; kk++) {
                    html += '<img src="' + item[kk] + '" style="cursor: pointer" onclick="layui.public.layerphotos(this,2)">';
                }
                return html;
            }
            return value || '';
        }
        this.GetRange = function (data = [], field = '') {
            var item = field.split(',');
            var s = data[item[0]] || '';
            var e = data[item[1]] || '';
            if (s && e) {
                return s + ' 至 ' + e;
            }
            return '';
        }
        this.ActionHtml = function (data = [], field = '', action = '', tableelem = '') {
            var str = '';
            var value = data[field] || '';
            switch (action) {
                case "switch":
                    var checked = '';
                    if (value == 1) {
                        checked = 'checked';
                    }
                    str += '<input type="checkbox" name="' + field + '" value="' + value + '" lay-skin="switch" lay-text="是|否" lay-filter="edit_table_switch" ' + checked + '/>';
                    break;
                case "input":
                    str += '<input name="' + field + '" placeholder="请输入" class="layui-input" value="' + value + '" onBlur="layui.rntable.EditInput(this)">';
                    break;
                case "date":
                    str += '<input  name="' + field + '" class="layui-input table-laydate" readonly placeholder="选择日期" value="' + value + '">';
                    break;
                case "select":
                    var value = layui.rntable.GetSource(value, field, tableelem);
                    str += '<div class="ruinuo_relative" lay-submit="" lay-filter="SelectShow" data-field="' + field + '"><input  name="' + field + '" class="layui-input table-dropdpwn" readonly placeholder="请选择" value="' + value + '"></div>';
                    break;
            }
            return str;
        }

        this.TableAction = function (find = [], tableelem = '') {
            var field = find.field || '';
            var action = find.action || '';
            var options = find.options || '';
            var imgs = find.imgs || '';
            var range = find.range || '';
            var tpl = find.tpl || '';
            var icon = find.icon || '';
            var str = '';
            if (tpl) {
                str = tpl;
            }
            if (action && str == '') {
                str += '{{- layui.rntable.ActionHtml(d,"' + field + '","' + action + '","' + tableelem + '") }}';
            }
            if (options && str == '') {
                str += '{{= layui.rntable.GetSource(d.' + field + ',"' + field + '","' + tableelem + '") }}';
            }

            if (imgs == 1 && str == '') {
                str += '{{- layui.rntable.GetImgs(d.' + field + ') }}';
            }
            if (range == 1 && str == '') {
                var data_field = find.data_field || '';
                str += '{{- layui.rntable.GetRange(d,"' + data_field + '") }}';
            }
            if (icon == 1 && str == '') {
                str += '<i class="ruinuo-icon {{d.' + field + '}}"></i>';
            }

            if (str) {
                return '<div>' + str + '</div>';
            }
            return '';
        }

        this.GetHeadButton = function (arr = [], cols) {
            var choose = 2;
            for (var k = 0; k < arr.length; k++) {
                var is_choose = arr[k]['is_choose'] || 2;
                if (is_choose == 1 && choose == 2) {
                    choose = 1;
                    var data = {type: 'checkbox', Width: 70};
                    cols[0].unshift(data);
                }
            }
            return cols;
        }


        this.getChooseData=function()
        {
            var checkStatus = layui.table.checkStatus('datatable');
            var checkStatusdata = checkStatus.data;
            if (checkStatusdata.length === 0) {
                layer.msg("未选中数据", {icon: 2});
                return false;
            }
            return checkStatusdata;
        }

        this.GetTableButton = function (table = []) {
            var str = '';
            var rows = table.button || [];
            var width=0;
            for (var k = 0; k < rows.length; k++) {
                var bgcolor = rows[k]['bgcolor'] || '#fff';
                var color = rows[k]['color'] || '#000';
                var icon = rows[k]['icon'] || '';
                var title = rows[k]['title'] || '';
                str += '<button class="pear-btn pear-btn-smm" style="background:' + bgcolor + ' ;color: ' + color + ';border-color: ' + bgcolor + '" data-index="' + k + '" lay-event="table_button">';
                if (icon) {
                    str += '<i class="' + icon + '" title="' + title + '"></i>';
                    width=width+60;
                } else {
                    str += '<span style="font-size: 12px">' + title + '</span>';
                    width=width+Number(title.length)*30;
                }
                str += '</button>';
            }
            if (str) {
                var data = {title: '操作', width: width, fixed: 'right', templet: '<div>' + str + '</div>'};
                table['cols'][0].push(data);
            }
        }

        this.GetTableData = function (table) {//加载表格数据
            try {
                AfterOnLoad(table);
            }
            catch (err)
            {
            }
            var style = table.style || 1;
            switch (style) {
                case 1:
                case 2:
                    layui.rntable.PtTable(table);
                    break;
                case 3:
                    layui.public.CardTable(table);
                    break;
            }

        };
        /*普通表格*/
        this.PtTable = function (table, data = []) {
            var style = table.style || 1;
            var token = localStorage.getItem('token') || '';
            var source = table.source || '';
            if (source != '') {
                TableConfig[table.elem] = table;
            }
            var render = layui.table;
            if (style == 2) {
                var render = layui.treeTable;
            }
            var lineStyle = table.lineStyle || '';
            render.render({
                elem: '#' + table.elem, tree: {
                    customName: {
                        name: 'title', pid: 'parent_id', icon: ''
                    },
                    view: {
                        expandAllDefault: true,
                    },
                }, height: table.height, method: 'post', loading: true, url: table.url, //数据接口
                where: layui.rntable.setTableData(),
                lineStyle: lineStyle,
                autoSort: false,
                skin:'line',
                page: table.page, //开启分页
                limits: [10, 30, 50, 100, 200, 300, 500], limit: table.limit,
                cols: table.cols, //表头
                even: true, data: data, headers: {token: token}, cellExpandedMode: 'tips', parseData: function (res) {
                    layer.closeAll('loading');
                    return {
                        "code": 0, "msg": "OK", "count": res.data.total, "data": res.data.rows
                    }
                }, done: function (res) {
                    var options = this;
                    layui.table.getRowData = function (elem) {
                        var index = $(elem).closest('tr').data('index');
                        var data = layui.table.cache[options.id][index] || {};
                        return {id: options.id, data: data};
                        //return layui.table.cache[options.id][index] || {};
                    };
                    layui.rntable.EditTableDate();
                    layui.rntable.EditTableSelect();
                    layui.rntable.EditTableSwitch();
                    layui.rntable.TableTips();
                    layui.rntable.TableBar(options.id);
                    layui.rntable.LoadTitle();
                    layui.rntable.DragSort(options.id, res.data);
                }
            })
        }


        this.TableXz = function (value = '', fiele = '', elem_id = '') {
            var str = layui.rntable.GetSource(value, fiele, elem_id) || '';
            var item = str.split(',') || [];
            var content = '';
            for (var k = 0; k < item.length; k++) {
                content += '<p class="xianzhi">' + item[k] + '</p>';
            }
            return content;
        }

        this.TableTips = function () {
            $('.table_tag').on('mouseenter', function () {
                var field = $(this).attr('tips-field');
                var res = layui.table.getRowData(this);

                var d = res.data;

                var content = '';
                switch (field) {
                    case "coupon_xianzhi":
                        content += '<ul>';
                        if (d.use_type == 2) {
                            content += '<li><p class="title">卖品限制</p>';
                            if (d.goods_type == 1) {
                                content += '<p class="no_title">不限制</p>';
                            } else {
                                content += layui.rntable.TableXz(d.goods_num, 'goods_num', res.id);
                            }
                        } else {
                            content += '<li><p class="title">影片</p>';
                            if (d.film_type == 1) {
                                content += '<p class="no_title">不限制</p>';
                            } else {
                                content += layui.rntable.TableXz(d.film_code, 'film_code', res.id);
                            }
                            content += '</li>';
                            content += '<li><p class="title">影厅</p>';
                            if (d.cinema_type == 1) {
                                content += '<p class="no_title">不限制</p>';
                            } else {
                                content += layui.rntable.TableXz(d.cinema_code, 'cinema_code', res.id);
                            }
                            content += '</li>';
                            var plan = eval(d.plan) || [];
                            content += '<li><p class="title">场次</p>';
                            if (d.plan_type == 1) {
                                content += '<p class="no_title">不限制</p>';

                            } else {
                                for (var k = 0; k < plan.length; k++) {
                                    var show=plan[k].plan_date;
                                    var plan_week=plan[k].plan_week || '';
                                    var plan_time=plan[k].plan_time || '';
                                    if (plan_week)
                                    {
                                        show+='（'+plan_week+'）';
                                    }
                                    if (plan_time)
                                    {
                                        show+='（'+plan_time+'）';
                                    }
                                    content += '<p class="xianzhi">' +show+ '</p>';
                                }


                            }
                            content += '<li><p class="title">适用门店</p>';
                            content += layui.rntable.TableXz(d.use_store, 'use_store', res.id);
                            content += '</li>';
                        }
                        content += '</ul>';
                        break;
                    case "priceplan_xianzhi":
                        var film_code = d.film_code || '';
                        var film_type = d.film_type || '';
                        var cinema_code = d.cinema_code || '';
                        var plan = eval(d.plan) || [];

                        content += '<ul>';

                        content += '<li><p class="title">影片</p>';
                        if (film_code) {
                            content += layui.rntable.TableXz(d.film_code, 'film_code', res.id);
                        } else {
                            content += '<p class="no_title">不限制</p>';
                        }
                        content += '<li><p class="title">电影类型</p>';
                        if (film_type) {
                            content += layui.rntable.TableXz(d.film_type, 'film_type', res.id);
                        } else {
                            content += '<p class="no_title">不限制</p>';
                        }
                        content += '<li><p class="title">影厅</p>';
                        if (cinema_code) {
                            content += layui.rntable.TableXz(d.cinema_code, 'cinema_code', res.id);
                        } else {
                            content += '<p class="no_title">不限制</p>';
                        }
                        content += '<li><p class="title">排期</p>';
                        if (plan.length!=0) {
                            for (var k = 0; k < plan.length; k++) {
                                var show=plan[k].plan_date;
                                var plan_week=plan[k].plan_week || '';
                                var plan_time=plan[k].plan_time || '';
                                if (plan_week)
                                {
                                    show+='（'+plan_week+'）';
                                }
                                if (plan_time)
                                {
                                    show+='（'+plan_time+'）';
                                }
                                content += '<p class="xianzhi">' +show+ '</p>';
                            }
                        } else {
                            content += '<p class="no_title">不限制</p>';
                        }

                        content += '</ul>';
                        break;
                    case "activity_list":
                        var list = eval(d.content) || [];
                        content += '<ul><li>';
                        for (var k = 0; k < list.length; k++) {
                            content += '<p class="xianzhi">' + list[k].coupon_name + '（' + list[k].coupon_num + '张）</p>';
                        }
                        content += '</li></ul>';
                        break;
                }

                this.index = layer.tips('<div class="tips_content">' + content + '</div>', this, {
                    time: -1, area: ['auto', 'auto'], tips: [3, '#fff']
                });
            }).on('mouseleave', function () {
                layer.close(this.index);
            });
        }

        this.DragSort = function (elem, res = []) {
            try {
                var length = $('.' + elem + ' tbody').length;
                if (length == 0) {
                    return false;
                }
                var tbody = document.querySelector('.' + elem + ' tbody');
                var sortable = Sortable.create(tbody, {
                    group: {
                        name: 'propertygroup',
                    },
                    ghostClass: "ghost",
                    handle: '.ruinuo-drag',
                    dataIdAttr: 'data-index',
                    animation: 150,
                    onEnd: function (evt) {
                        var arr = sortable.toArray();
                        var dataBak = [];
                        for (var k = 0; k < arr.length; k++) {
                            dataBak.push(res[arr[k]])
                        }
                        layui.table.reload(elem, {
                            data: dataBak, url: '',
                        })
                        layui.rntable.BackAction(dataBak, elem);
                    }
                });
            } catch (err) {
                console.log(err)
            }
        }

        this.GetSelect = function () {//表格筛选
            layui.form.on('submit(search_select)', function (obj) {
                var field = obj.elem.id;
                var elem = $(obj.elem).attr('data-table');
                var source = TableConfig[elem].source || [];
                var newdata = source[field] || [];
                var newdata = newdata['rows'] || [];
                layui.dropdown.render({
                    elem: obj.elem,
                    show: true,
                    data: newdata,
                    customName: {
                        id: 'value',
                        title: 'label',
                    },
                    align: 'right',
                    style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);',
                    click: function (data, othis) {
                        SeleteData[field] = data;
                        layui.rntable.tableReload(elem);
                    }
                });
            });
        }


        this.setTableData = function () {//表格参数
            tab_num = $('.head_menu li.on').attr('data-num') || 'all';
            var search = {};
            $(".table_from_item *[name]").each(function (kk) {
                var name = $(this).attr("name");
                var value = $(this).val();
                if (value) {
                    search[name] = value;
                }
            })
            var urldata = layui.public.GetQueryAll() || {};
            var item = SeleteData || [];
            $.each(item, function (key, res) {
                var value = res['value'] || '';
                if (value) {
                    urldata[key] = value;
                }
            })
            var data = {
                "tab_num": tab_num,
                "group_num": group_num,
                "search": JSON.stringify(search),
                "urldata": JSON.stringify(urldata),
                'orderraw': orderraw
            }
            return data;
        };

        this.LoadTitle = function () {
            $(".table_search").each(function () {
                var field = $(this).attr("id");
                var item = SeleteData[field] || [];
                var value = item['value'] || '';
                var title = $("#title_" + field).attr('data-title') || '';
                var data_title = item['label'] || '';

                if (value) {
                    $("#title_" + field).html(data_title);
                    $("#title_" + field).parent(".table_title").parent("span").parent("div").addClass("table_title_on");
                } else {
                    $("#title_" + field).html(title);
                    $("#title_" + field).parent(".table_title").parent("span").parent("div").removeClass("table_title_on");
                }
            });
        }

        /*新增数据表格*/
        this.AddTable = function (tableelem) {
            var dataBak = [];
            var tableBak = layui.table.cache[tableelem];
            for (var i = 0; i < tableBak.length; i++) {
                dataBak.push(tableBak[i]);
            }
            dataBak.push({});
            layui.table.reload(tableelem, {
                data: dataBak, url: '',
            })
            layui.rntable.BackAction(dataBak, tableelem);
        }

        /*删除数据表格*/
        this.DeleteTable = function (tableelem = '', index = 0) {
            var dataBak = [];
            var tableBak = layui.table.cache[tableelem];
            for (var i = 0; i < tableBak.length; i++) {
                if (i != index) {
                    dataBak.push(tableBak[i]);
                }
            }
            layui.table.reload(tableelem, {
                data: dataBak, url: '',
            })
            layui.rntable.BackAction(dataBak, tableelem);
        }
        this.EditInput = function (obj) {
            var res = layui.table.getRowData(obj);
            var tableelem = res.id || '';
            var data = res.data;
            var id = data.id || '';
            var field = $(obj).attr('name');
            data[field] = $(obj).val();
            var dataBak = layui.table.cache[tableelem];
            if (id) {
                var postdata = {id: id, field: field, value: data[field]};
                console.log('提交');
            }
            layui.rntable.BackAction(dataBak, tableelem, postdata);
        }

        this.EditTableDate = function () {
            layui.laydate.render({
                elem: '.table-laydate', done: function (value, date, endDate) {
                    var res = layui.table.getRowData(this.elem);
                    var tableelem = res.id || '';
                    var data = res.data;
                    var id = data.id || '';
                    var field = $(obj).attr('name');
                    data[field] = value;
                    var dataBak = layui.table.cache[tableelem];
                    layui.rntable.BackAction(dataBak, tableelem);
                    if (id) {
                        var postdata = {id: id, field: field, value: value};
                        console.log('提交');
                    }
                    layui.rntable.BackAction(dataBak, tableelem, postdata);
                }
            });
        }
        this.EditTableSelect = function () {
            layui.form.on('submit(SelectShow)', function (obj) {
                var elem = obj.elem;
                var field = $(elem).attr("data-field");
                var res = layui.table.getRowData(elem);
                var tableelem = res.id || '';
                var id = res.data.id || '';
                var rows = TableConfig[tableelem]['source'][field] || [];
                var newdata = rows.rows || [];
                layui.dropdown.render({
                    elem: elem,
                    show: true,
                    data: newdata,
                    customName: { // 自定义 data 字段名 --- 2.8.14+
                        id: 'value',
                        title: 'label',
                    },
                    click: function (data, othis) {
                        $(elem).find("input").val(data.label);
                        res.data[field] = data.value;
                        var dataBak = layui.table.cache[tableelem];
                        if (id) {
                            var postdata = {id: id, field: field, value: data.value};
                            console.log('提交');
                        }
                        layui.rntable.BackAction(dataBak, tableelem, postdata);
                    }
                });


            })
        }

        this.EditTableSwitch = function () {
            layui.form.on('switch(edit_table_switch)', function (obj) {

                var res = layui.table.getRowData(obj.elem);
                var tableelem = res.id || '';
                var id = res.data.id || '';
                if (obj.elem.checked) {
                    res.data[obj.elem.name] = 1;
                } else {
                    res.data[obj.elem.name] = 2;
                }

                var dataBak = layui.table.cache[tableelem];
                if (id) {
                    var postdata = {id: id, field: obj.elem.name, value: res.data[obj.elem.name]};
                    console.log('提交');
                }
                layui.rntable.BackAction(dataBak, tableelem, postdata);
            })
        }


        this.TableBar = function (tableelem) {
            layui.table.on('tool(' + tableelem + ')', function (obj) {
                var layEvent = obj.event;
                var that = this;
                var index = $(that).attr('data-index') || 0;
                var rows = obj.data;
                switch (layEvent) {
                    case "table_button":
                        layui.rntable.SaveButton(index, 2, tableelem, rows)
                        break;
                    case "dropdown":
                        layui.dropdown.render({
                            elem: that, show: true, // 外部事件触发即显示
                            data: [{
                                title: 'ite1111m 1', id: 'aaa'
                            }, {
                                title: 'it2222222222222em2', id: 'bbb'
                            }, {
                                title: '删除', id: 'del'
                            }], click: function (data, othis) {
                                console.log(rows, data)
                            }, align: 'right', // 右对齐弹出
                            style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
                        })
                        break;
                }
            });
        }


        this.SaveButton = function (index = 0, type = 1, tableelem = '', d = []) {
            var data = [];

            switch (type) {
                case 1:
                    data = TableConfig[tableelem]['header']['button'][index] || [];
                    break;
                case 2:
                    data = TableConfig[tableelem]['table']['button'][index] || [];
                    break;
            }
            var url = data['url'] || '';
            var title = data['title'] || '';
            var width = data['width'] || '0';
            var height = data['height'] || '0';
            var choose = data['is_choose'] || 2;
            if (choose == 1 && type == 1) {
                var checkStatus = layui.table.checkStatus('' + tableelem + '');
                var checkStatusdata = checkStatus.data;
                if (checkStatusdata.length === 0) {
                    layer.msg("未选中数据", {icon: 2});
                    return false;
                }
                var ids = "";
                for (var i = 0; i < checkStatusdata.length; i++) {
                    ids += checkStatusdata[i].id + ",";
                }
                d['id'] = ids.substr(0, ids.length - 1);
            }
            url = layui.public.GetUrl(d, url);
            switch (data['open']) {
                case "window":
                    url += "&elem=" + tableelem;
                    layui.public.OpenWindow(url, title, width, height);
                    break;
                case "ajax":
                    layui.public.OpenAjax(url, title, "layui.rntable.tableReload(\"" + tableelem + "\",1);");
                    break;
                case "location":
                    window.location.href =url;
                    break;
            }
        }


        this.tableReload = function (elem = '', type = '') {//重新加载表格
            var elem = elem || 'datatable';
            var config = TableConfig[elem] || [];
            var table = config.table || [];
            var page = table.page || false;
            if (type && page) {
                $(".layui-laypage-btn").click();//只刷新当前页
                return false;
            }
            layui.rntable.GetTableData(table);
        }

        this.BackReload = function (elem = '') {
            var elem = elem || 'datatable';
            var config = TableConfig[elem] || [];
            var table = config.table || [];
            $('.table_from_item input').val("");
            $('.table_from_item select').find("option:selected").attr("selected", false);
            SeleteData = {};
            layui.rntable.GetTableData(table);
        }

        this.GetSort = function (obj) {
            orderraw = $(obj).attr("data-val");
            layui.rntable.tableReload();
        }

        this.BackAction = function (arr = [], tableelem = '', postdata = '') {
            var id = tableelem.replace("table", "focus");
            var value = JSON.stringify(arr);
            $('#' + id).val(value);
            var config = TableConfig[tableelem] || [];
            var table = config['table'] || [];
            var up_field = table['up_field'] || '';
            switch (tableelem) {
                case "design_table_elem":
                    layui.design_table.EditCols(arr);
                    break;
                default:
                    try {
                        if (up_field && postdata) {
                            layui.http.SendAjax(up_field, postdata, [], function (res) {
                                if (res.code != 200) {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            })
                        }
                        TableAction(id);
                    } catch (err) {

                    }
            }

        }
    }
    exports(MOD_NAME, context);
});

